﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Roton.Engine.Structures
{
    static class IntegerExtensions
    {
        static public Boolean ToBool(this Byte value) { return value != 0; }
        static public Boolean ToBool(this Int16 value) { return value != 0; }
        static public Boolean ToBool(this Int32 value) { return value != 0; }
        static public Byte ToByte(this Int16 value) { return (Byte)(value & 0xFF); }
        static public Byte ToByte(this Int32 value) { return (Byte)(value & 0xFF); }
        static public Byte ToByte(this Boolean value) { return (Byte)(value ? 1 : 0); }
        static public Int16 ToInt16(this Byte value) { return (Int16)value; }
        static public Int16 ToInt16(this Int32 value) { return (Int16)((value << 16) >> 16); }
        static public Int16 ToInt16(this Boolean value) { return (Int16)(value ? 1 : 0); }
        static public Int32 ToInt32(this Byte value) { return (Int32)value; }
        static public Int32 ToInt32(this Int16 value) { return (Int32)value; }
        static public Int32 ToInt32(this Boolean value) { return (Int32)(value ? 1 : 0); }
    }
}
